<!DOCTYPE html>
<html lang="zh">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="dromara.org" />
	<meta name="description" content="dromara.org" />
	<!-- 网页标签标题 -->
	<title>dromara(Open source organization)</title>
	<link rel="shortcut icon" href="/website/img/docsite.ico"/>
	<link rel="stylesheet" href="/website/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/website/en-us/index.html"><img class="logo" src="/website/img/dromara.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">中</span><div class="header-menu"><img class="header-menu-toggle" src="/website/img/system/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/website/en-us/index.html" target="_self">Home</a><div class="sub-menu"><ul></ul></div></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="#">Document</a><div class="sub-menu"><ul><li><a href="/website/en-us/docs/soul/soul.html" target="_self">Soul</a></li><li><a href="/website/en-us/docs/hmily/index.html" target="_self">Hmily</a></li></ul></div></li><li class="menu-item menu-item-normal"><a href="/website/en-us/blog/index.html" target="_self">Blog</a><div class="sub-menu"><ul></ul></div></li><li class="menu-item menu-item-normal"><a href="/website/en-us/community/index.html" target="_self">Community</a><div class="sub-menu"><ul></ul></div></li></ul></div></div></header><section class="content-section"><div class="sidemenu" id="menu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>Soul</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/soul.html" target="_self">Home  </a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/team.html" target="_self">Team</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/db.html" target="_self">Database Design</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/config.html" target="_self">Config</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/dataSync.html" target="_self">DataSync</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/en-us/docs/soul/metaData.html" target="_self">MetaData</a></li><li style="height:792px;overflow:hidden" class="menu-item menu-item-level-2"><span>User Document<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/setup.html" target="_self">Set up</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/soul-dict.html" target="_self">Dictionary management</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-handle.html" target="_self">Plugin handle explanation</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/user-http.html" target="_self">Http proxy</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/user-dubbo.html" target="_self">Dubbo proxy</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/user-springcloud.html" target="_self">Spring cloud proxy</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/user-sofa.html" target="_self">Sofa rpc proxy</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/selector.html" target="_self">Selector and Rule</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/user-dataSync.html" target="_self">Use data sync</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-divide.html" target="_self">Divide Plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-dubbo.html" target="_self">Dubbo plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-springcloud.html" target="_self">Spring cloud plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-sofa.html" target="_self">Sofa plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-rateLimiter.html" target="_self">RateLimiter plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-hystrix.html" target="_self">Hystrix plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-sentinel.html" target="_self">Sentinel plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-monitor.html" target="_self">Monitor plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-waf.html" target="_self">Waf plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-sign.html" target="_self">Sign plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-rewrite.html" target="_self">Rewrite plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/plugin-websocket.html" target="_self">Websocket plugin</a></li></ul></li><li style="height:360px;overflow:hidden" class="menu-item menu-item-level-2"><span>Developer Guide<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-filter.html" target="_self">Custom filter </a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-plugin.html" target="_self">Custom plugin</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-file.html" target="_self">File and Image</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-iphost.html" target="_self">Custom parsing IP and Host</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-result.html" target="_self">Custom result</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-sign.html" target="_self">Custom sign algorithm</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-client.html" target="_self">Developer soul client</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-thread.html" target="_self">Thread</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/dev-netty.html" target="_self">Soul optimize</a></li></ul></li><li style="height:144px;overflow:hidden" class="menu-item menu-item-level-2"><span>Community<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/contributor.html" target="_self">Contributor</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/committer.html" target="_self">Committer</a></li><li class="menu-item menu-item-level-3"><a href="/website/en-us/docs/soul/code-conduct.html" target="_self">Code conduct</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body" id="doc-body"><h2>Features</h2>
<ul>
<li>
<p>Data synchronization is the key of gateway high performance, which is to sync 'soul-admin' config data into the JVM memory of soul cluster.</p>
</li>
<li>
<p>Implementation principles, pls refer to：<a href="dataSync.md">dataSync</a>。</p>
</li>
<li>
<p>In the article, the gateway is the environment you setup. please refer to：<a href="setup.md">Environment Setup</a>.</p>
</li>
</ul>
<h2>Websocket sync（default method，recommend）</h2>
<ul>
<li>
<p>gateway setting（note:restart）</p>
<ul>
<li>Add these dependencies in <code>pom.xml</code>：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use websocket--&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-websocket<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>add these config values in springboot yaml file:</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
    <span class="hljs-attr">sync:</span>
        <span class="hljs-attr">websocket :</span>
             <span class="hljs-attr">urls:</span> <span class="hljs-string">ws://localhost:9095/websocket</span>
<span class="hljs-comment">#urls: address of soul-admin，multi-address will be splitted with (,).</span>
</code></pre>
<ul>
<li>soul-admin config, enable this parameter <code>--soul.sync.websocket=''</code> in soul admin, then restart service.</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
     <span class="hljs-attr">websocket:</span>
</code></pre>
<ul>
<li>
<p>When the connection is established, getting the full data once,then adding and upating data subsequently, which is a good performance.</p>
</li>
<li>
<p>Support disconnection and reconnection (default 30 sec).</p>
</li>
</ul>
<h2>zookeeper sync</h2>
<ul>
<li>
<p>gateway setting（note: restart）</p>
<ul>
<li>Add these dependencies in <code>pom.xml</code>:</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-zookeeper<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>Add these dependencies in  springboot yaml file:</li>
</ul>
<pre><code class="language-yaml"> <span class="hljs-attr">soul :</span>
     <span class="hljs-attr">sync:</span>
         <span class="hljs-attr">zookeeper:</span>
              <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:2181</span>
              <span class="hljs-attr">sessionTimeout:</span> <span class="hljs-number">5000</span>
              <span class="hljs-attr">connectionTimeout:</span> <span class="hljs-number">2000</span>
 <span class="hljs-comment">#url: config with your zk address, used by the cluster environment, splitted with (,).</span>
</code></pre>
<ul>
<li>soul-admin config: configure the soul-admin's starting parameter with <code>--soul.sync.zookeeper.url='your address'</code>,then restart the service.</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
    <span class="hljs-attr">zookeeper:</span>
        <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:2181</span>
        <span class="hljs-attr">sessionTimeout:</span> <span class="hljs-number">5000</span>
        <span class="hljs-attr">connectionTimeout:</span> <span class="hljs-number">2000</span>
</code></pre>
<ul>
<li>It is  good to use ZooKeeper synchronization mechanism with high timeliness, but we also have to deal with the unstable environment of ZK, cluster brain splitting and other
problems.</li>
</ul>
<h2>Http long-polling sync</h2>
<ul>
<li>
<p>gateway setting（note:restart）</p>
<ul>
<li>Add these dependencies in <code>pom.xml</code>：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-http<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>add these config values in your springboot yaml file:</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
   <span class="hljs-attr">sync:</span>
       <span class="hljs-attr">http:</span>
            <span class="hljs-attr">url:</span> <span class="hljs-string">http://localhost:9095</span>
<span class="hljs-comment">#url: config with your soul-admin's ip and port url, pls use (,) to split multi-admin cluster environment.</span>
</code></pre>
<ul>
<li>soul-admin config, configure the soul-admin's starting parameter with <code>--soul.sync.http=''</code>, then restart service.</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
     <span class="hljs-attr">http:</span>
</code></pre>
<ul>
<li>
<p>HTTP long-polling makes the gateway lightweight, but less time-sensitive.</p>
</li>
<li>
<p>It pulls according to the group key, if the data is too large, it will have some influences, a small change under a group will pull the entire group.</p>
</li>
<li>
<p>it may hit bug in soul-admin cluster.</p>
</li>
</ul>
<h2>nacos sync</h2>
<ul>
<li>
<p>gateway setting（note:restart）</p>
<ul>
<li>Add these dependencies in your <code>pom.xml</code>：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-nacos<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>add these config values in the springboot yaml file:</li>
</ul>
<pre><code class="language-yaml"> <span class="hljs-attr">soul :</span>
     <span class="hljs-attr">sync:</span>
        <span class="hljs-attr">nacos:</span>
             <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:8848</span>
             <span class="hljs-attr">namespace:</span> <span class="hljs-string">1c10d748-af86-43b9-8265-75f487d20c6c</span>
             <span class="hljs-attr">acm:</span>
               <span class="hljs-attr">enabled:</span> <span class="hljs-literal">false</span>
               <span class="hljs-attr">endpoint:</span> <span class="hljs-string">acm.aliyun.com</span>
               <span class="hljs-attr">namespace:</span> 
               <span class="hljs-attr">accessKey:</span> 
               <span class="hljs-attr">secretKey:</span> 
 <span class="hljs-comment"># url: config with your nacos address, pls use (,) to split your cluster environment.</span>
 <span class="hljs-comment"># other configure，pls refer to the naocs website.</span>
</code></pre>
<ul>
<li>soul-admin config: passing values one by one with '--' operator in the soul-Admin startup parameter.</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
      <span class="hljs-attr">sync:</span>
         <span class="hljs-attr">nacos:</span>
              <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:8848</span>
              <span class="hljs-attr">namespace:</span> <span class="hljs-string">1c10d748-af86-43b9-8265-75f487d20c6c</span>
              <span class="hljs-attr">acm:</span>
                <span class="hljs-attr">enabled:</span> <span class="hljs-literal">false</span>
                <span class="hljs-attr">endpoint:</span> <span class="hljs-string">acm.aliyun.com</span>
                <span class="hljs-attr">namespace:</span> 
                <span class="hljs-attr">accessKey:</span> 
                <span class="hljs-attr">secretKey:</span> 
</code></pre>
</div></section><footer class="footer-container"><div class="footer-body"><img src="/website/img/dromara.png"/><div class="cols-container"><div class="col col-12"><h3>Disclaimer</h3><p>Any unit or individual reprint all relevant information of this website, please indicate the source.</p></div><div class="col col-6"><dl><dt>Document</dt><dd><a href="/website/en-us/docs/soul/soul.html" target="_self">Overview </a></dd><dd><a href="/website/en-us/docs/soul/soul.html" target="_self">Stat up</a></dd><dd><a href="/website/en-us/docs/soul/soul.html" target="_self">Developer Guide</a></dd></dl></div><div class="col col-6"><dl><dt>Resource</dt><dd><a href="/website/en-us/blog/index.html" target="_self">Blog</a></dd><dd><a href="/website/en-us/community/index.html" target="_self">Community</a></dd></dl></div></div><div class="copyright"><span>Copyright ©2020 xiaoyu@apache.org by xiaoyu</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '/website';
  </script>
	<script src="/website/build/documentation.js"></script>
</body>
</html>